import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;



public class TestMac {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		getMACAddress("192.168.6.100");
	}
	public static String getMACAddress(String ip){ 
        String str = ""; 
        String macAddress = ""; 
        try { 
            Process p = Runtime.getRuntime().exec("nbtstat -A " + ip); 
            InputStreamReader ir = new InputStreamReader(p.getInputStream(),"GBK"); 
            LineNumberReader input = new LineNumberReader(ir); 
            for (int i = 1; i < 100; i++) { 
                str = input.readLine(); 
                if (str != null) { 
                	System.out.println(str);
                    if (str.indexOf("=") > 1) { 
                        macAddress = str.substring(str.indexOf("=")+1, str.length()).trim(); 
                        break; 
                    } 
                } 
            } 
        } catch (IOException e) { 
            e.printStackTrace(System.out); 
        } 
        System.out.println(macAddress);
        System.out.println(macAddress.length());
        return macAddress; 
    } 
}
